package com.fund.datacopy.conf;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Set;
import org.apache.commons.lang.StringUtils;

import com.aug3.sys.props.PropertyLoader;

public class ConfigureManger {
	private static final String resourceName = "/app.properties";
	private static Properties perperty = new Properties();

	static {
		load();
	}

	private static void load() {

		try {

			InputStream in = PropertyLoader.class.getResourceAsStream(resourceName);

			if (in == null) {
				return;
			}

			try {
				perperty.load(in);
			} finally {
				in.close();
			}

		} catch (IOException e) {

			throw new RuntimeException("failed loading configuration data from " + resourceName, e);

		}
	}

	public static String getAsString(String key) {
		return perperty.getProperty(key);
	}

	public static Integer getAsInt(String key) {
		String val = perperty.getProperty(key);
		if (StringUtils.isNotBlank(val)) {
			return Integer.valueOf(val);
		}
		return null;
	}

	public static Set<Object> getAllKeys() {
		return perperty.keySet();
	}
}
